import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/index',
    name: '首页',
    hidden: true,
    children: [{
      path: 'index',
      component: () => import('@/views/dashboard/index')
    }]
  },

  // 角色管理
  {
    path: '/system',
    component: Layout,
    redirect: '/system/roles',
    name: '管理员管理',
    meta: { title: '管理员管理', icon: 'role' },
    children: [
      {
        path: 'admin',
        name: '管理员列表',
        component: () => import('@/views/system/admin/index'),
        meta: { title: '管理员列表', icon: 'role', noCache: true }
      }
    ]
  },

  // 用户管理
  {
    path: '/user',
    component: Layout,
    redirect: '/user/userlist',
    name: '用户管理',
    meta: { title: '用户管理', icon: 'user' },
    children: [
      {
        path: 'userlist',
        name: '用户列表',
        component: () => import('@/views/user/userList/index'),
        meta: { title: '用户列表', icon: 'user' }
      }
    ]
  },

  // 预约管理
  {
    path: '/appointment',
    component: Layout,
    redirect: '/appointment/appointmentList',
    name: '预约管理',
    meta: { title: '预约管理', icon: 'appoint' },
    children: [
      {
        path: 'appointmentList',
        name: '预约列表',
        component: () => import('@/views/appointment/appointmentList/index'),
        meta: { title: '预约列表', icon: 'appoint' }
      }
    ]
  },

  // 设备管理
  {
    path: '/device',
    component: Layout,
    redirect: '/device/devicelist',
    name: '设备管理',
    meta: { title: '设备管理', icon: 'example' },
    children: [
      {
        path: 'devicelist',
        name: '设备列表',
        component: () => import('@/views/device/deviceList/index'),
        meta: { title: '设备列表', noCache: true }
      },
      {
        path: 'deviceType',
        name: '设备类型',
        component: () => import('@/views/device/deviceTypeList/index'),
        meta: { title: '设备类型', noCache: true }
      },
      {
        path: 'parameter',
        name: '参数配置',
        component: () => import('@/views/device/parameter/index'),
        meta: { title: '参数配置', noCache: true }
      },
      {
        path: 'deviceputIn/:uuid',
        name: '设备投放列表',
        component: () => import('@/views/device/deviceputInList/index'),
        hidden: true,
        meta: { title: '设备投放列表', noCache: false }
      },
      {
        path: 'putIn',
        name: '投放列表',
        component: () => import('@/views/device/putInList/index'),
        meta: { title: '投放列表', noCache: true }
      },
      {
        path: 'full',
        name: '满桶列表',
        component: () => import('@/views/device/fullList/index'),
        meta: { title: '满桶列表', noCache: true }
      },
      {
        path: 'false',
        name: '故障列表',
        component: () => import('@/views/device/malfunction/index'),
        meta: { title: '故障列表', noCache: true }
      },
      {
        path: 'insRecord',
        name: '巡检记录',
        component: () => import('@/views/device/insRecord/index'),
        meta: { title: '巡检记录', noCache: true }
      }
    ]
  },

  // 地区管理
  {
    path: '/region',
    component: Layout,
    redirect: '/region/regionList',
    name: '地区管理',
    meta: { title: '地区管理', icon: 'area' },
    children: [
      {
        path: 'regionList',
        name: '地区列表',
        component: () => import('@/views/region/regionList/index'),
        meta: { title: '地区列表', noCache: true }
      },
      {
        path: 'community',
        name: '社区列表',
        component: () => import('@/views/region/community/index'),
        meta: { title: '社区列表', noCache: true }
      }
    ]
  },

  // 商城管理
  {
    path: '/commodity',
    component: Layout,
    redirect: '/commodity/commodityList',
    name: '商城管理',
    meta: { title: '商城管理', icon: 'shopping' },
    children: [
      {
        path: 'integralList',
        name: '商品类型列表',
        component: () => import('@/views/commodity/integralList/index'),
        meta: { title: '商品类型列表', noCache: true }
      },
      {
        path: 'commodityList',
        name: '商品列表',
        component: () => import('@/views/commodity/commodityList/index'),
        meta: { title: '商品列表', noCache: true }
      },
      {
        path: 'exchangeList',
        name: '兑换记录',
        component: () => import('@/views/commodity/exchangeList/index'),
        meta: { title: '兑换记录', noCache: true }
      },
      {
        path: 'PointRules',
        name: '积分规则',
        component: () => import('@/views/commodity/PointRules/index'),
        meta: { title: '积分规则', noCache: true }
      }
    ]
  },

  // 新闻管理
  {
    path: '/news',
    component: Layout,
    redirect: '/news/newsList',
    name: '新闻管理',
    meta: { title: '新闻管理', icon: 'news' },
    children: [
      {
        path: 'newsList',
        name: '新闻列表',
        component: () => import('@/views/news/newsList/index'),
        meta: { title: '新闻列表', noCache: true }
      },
      {
        path: 'newTypeList',
        name: '新闻类型列表',
        component: () => import('@/views/news/newTypeList/index'),
        meta: { title: '新闻类型列表', noCache: true }
      }
    ]
  },

  // banner管理
  {
    path: '/banner',
    component: Layout,
    redirect: '/banner/bannerList',
    name: 'banner管理',
    meta: { title: 'banner管理', icon: 'banner' },
    children: [
      {
        path: 'bannerList',
        name: 'banner列表',
        component: () => import('@/views/banner/bannerList/index'),
        meta: { title: 'banner列表', icon: 'banner' }
      }
    ]
  },
  // 意见反馈管理
  {
    path: '/feedback',
    component: Layout,
    redirect: '/feedback/feedbackList',
    name: '意见反馈',
    meta: { title: '意见反馈', icon: 'banner' },
    children: [
      {
        path: 'feedbackList',
        name: '意见反馈列表',
        component: () => import('@/views/feedback/feedbackList/index'),
        meta: { title: '意见反馈列表', icon: 'banner' }
      }
    ]
  },
  // // 参数管理
  // {
  //   path: '/parameters',
  //   component: Layout,
  //   redirect: '/parameters/parametersList',
  //   name: '参数管理',
  //   meta: { title: '参数管理', icon: 'news' },
  //   children: [
  //     {
  //       path: 'parametersList',
  //       name: '参数列表',
  //       component: () => import('@/views/parameters/parametersList/index'),
  //       meta: { title: '参数列表', noCache: true }
  //     },
  //     {
  //       path: 'newTypeList',
  //       name: '新闻类型列表',
  //       component: () => import('@/views/parameters/newTypeList/index'),
  //       meta: { title: '新闻类型列表', noCache: true }
  //     }
  //   ]
  // },

  {
    path: '/example',
    component: Layout,
    redirect: '/example/table',
    name: 'Example',
    hidden: true,
    meta: { title: 'Example', icon: 'example' },
    children: [
      {
        path: 'table',
        name: 'Table',
        component: () => import('@/views/table/index'),
        meta: { title: 'Table', icon: 'table' }
      },
      {
        path: 'tree',
        name: 'Tree',
        component: () => import('@/views/tree/index'),
        meta: { title: 'Tree', icon: 'tree' }
      },
      {
        path: 'features',
        name: '功能组件展示',
        component: () => import('@/views/Example/index'),
        meta: { title: 'Example', icon: 'example' }
      }
    ]
  },
  //
  // {
  //   path: '/form',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       name: 'Form',
  //       component: () => import('@/views/form/index'),
  //       meta: { title: 'Form', icon: 'form' }
  //     }
  //   ]
  // },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

